package com.mindskip.xzs.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mindskip.xzs.base.PageResult;
import com.mindskip.xzs.base.QueryPageBean;
import com.mindskip.xzs.domain.TWjTm;
import com.mindskip.xzs.domain.WJ;
import com.mindskip.xzs.repository.BaseMapper;
import com.mindskip.xzs.repository.TWjTmMapper;
import com.mindskip.xzs.service.TWjTmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TWjTmServiceImpl extends BaseServiceImpl<TWjTm> implements TWjTmService {

    @Autowired
    private  TWjTmMapper tWjTmMapper;

    public TWjTmServiceImpl(BaseMapper<TWjTm> baseMapper) {
        super(baseMapper);
    }

    @Override
    public PageResult findByCondition(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();//获取当前页面
        Integer pageSize = queryPageBean.getPageSize();//获取每页显示的记录数
        String queryString = queryPageBean.getQueryString();//获取查询条件
        //分页插件，会在执行sql之前将分页关键字追加到SQL后面
        PageHelper.startPage(currentPage,pageSize);
        //调用持久层接口方法
        Page<TWjTm> page = tWjTmMapper.findByCondition(queryString);
        //返回分页结果对象
        return new PageResult(page.getTotal(),page.getResult());

    }

    @Override
    public int insertTWjTm(TWjTm tWjTm) {
        return tWjTmMapper.insertTWjTm(tWjTm);
    }

    @Override
    public int updateTWjTm(TWjTm tWjTm) {
        return tWjTmMapper.updateTWjTm(tWjTm);
    }

    @Override
    public int deleteTWjTmById(Integer id) {
        return tWjTmMapper.deleteTWjTmById(id);
    }


//    @Autowired
//    public TWjTmServiceImpl(SubjectMapper subjectMapper) {
//        super(subjectMapper);
//        this.subjectMapper = subjectMapper;
//    }
//
//    @Override
//    public Subject selectById(Integer id) {
//        return super.selectById(id);
//    }
//
//    @Override
//    public int updateByIdFilter(Subject record) {
//        return super.updateByIdFilter(record);
//    }
//
//    @Override
//    public List<Subject> getSubjectByLevel(Integer level) {
//        return subjectMapper.getSubjectByLevel(level);
//    }
//
//    @Override
//    public List<Subject> allSubject() {
//        return subjectMapper.allSubject();
//    }
//
//    @Override
//    public Integer levelBySubjectId(Integer id) {
//        return this.selectById(id).getLevel();
//    }
//
//    @Override
//    public PageInfo<Subject> page(SubjectPageRequestVM requestVM) {
//        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
//                subjectMapper.page(requestVM)
//        );
//    }

}
